package com.huawei.appmarket.service.alarm;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.huawei.appmarket.service.alarm.control.BasePowerConnectChangeService;
import com.huawei.secure.android.common.intent.SafeIntent;
import o.dha;
import o.dhq;
import o.Logger;
import o.ewm.n;

public class PowerConnectChangeReceiver extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent) {
        if (context == null) {
            Logger.ˎ("PowerConnectedReceiver", "context is null");
        } else if (dhq.ॱ().ˎ()) {
            SafeIntent safeIntent = new SafeIntent(intent);
            try {
                Class ˋ = dha.ˋ(context.getString(n.ʼㆍ));
                if (ˋ != null) {
                    Intent intent2 = new Intent(context, ˋ);
                    int i = 0;
                    if ("android.intent.action.ACTION_POWER_CONNECTED".equals(safeIntent.getAction())) {
                        Logger.ˏ("PowerConnectedReceiver", "get ACTION_POWER_CONNECTED");
                        i = 1;
                    } else if ("android.intent.action.ACTION_POWER_DISCONNECTED".equals(safeIntent.getAction())) {
                        Logger.ˏ("PowerConnectedReceiver", "get ACTION_POWER_DISCONNECTED");
                        i = 2;
                    }
                    intent2.putExtra(BasePowerConnectChangeService.INTENT_TYPE_KEY, i);
                    context.startService(intent2);
                }
            } catch (SecurityException e) {
                Logger.e("PowerConnectedReceiver", "startService SecurityException");
            } catch (Exception e2) {
                Logger.e("PowerConnectedReceiver", "startService exception");
            }
        } else {
            Logger.ˏ("PowerConnectedReceiver", "has not agree protocol");
        }
    }
}
